from keras.models import model_from_json
from keras.models import Sequential
from data_utils import tokenize_and_vectorize
from data_utils import pad_trunc
import numpy as np
import h5py
cnn_weights_path = 'cnn_weights.h5'
maxlen = 400
embedding_dims = 300
model = Sequential()


with open('result/cnn_model.json', 'r', encoding='utf-8') as f:
    json_string = f.read()

model = model_from_json(json_string)
model.load_weights(cnn_weights_path)
sample1 = 'I do not like this movie,i have to say:it is beyond my imagination'

vec_list = tokenize_and_vectorize([(1, sample1)])

test_vec_list = pad_trunc(vec_list, maxlen=400)

test_vec = np.reshape(test_vec_list, (len(test_vec_list), maxlen, embedding_dims))

model.predict(test_vec)

predict_text = model.predict_classes(test_vec)
print(predict_text)
